<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:common="http://java.sun.com/jsf/composite/common">
<h:body>
	<ui:composition template="/pages/templates/MainTemplate.xhtml">
		<ui:define name="content">
			<h:form id="approveForm">
				<p:growl id="itemDataGrwol" globalOnly="true" showDetail="true"
					autoUpdate="true" showSummary="true" />
				<h3>
					<h:outputText value="#{apprMB.taskDescription}"></h:outputText>
				</h3>
				<p:outputPanel id="item_approve_panel" styleClass="tableNoGrid">
					<p:panelGrid
						rendered="#{apprMB.taskDefKey == 'aprobacionItemNuevoProd' or apprMB.taskDefKey == 'approveNewItemAdmin'}">
						<p:row>
							<p:column colspan="5">
								<!--ITEM DATA  -->
								<common:itemData tiposMaterial="#{itemsMB.tiposMaterial}"
									muestraDialogListner="#{itemsMB.getResultMuestra}"
									tipoMaterialSeleccionado="#{itemsMB.tipoMaterialSeleccionado}"
									isModal="false" item="#{apprMB.item}" readOnly="true"
									chooseItem="false" id="itemsData" container="itemsPanel"
									parentId="approveForm" />
							</p:column>
						</p:row>
						<p:row>
							<p:column style="max-width: 59px;"
								rendered="#{apprMB.taskDefKey == 'approveNewItemAdmin'}">
								<p:outputLabel value="Codigo de item: " for="codigo_item"></p:outputLabel>
							</p:column>
							<p:column style="max-width: 74px;"
								rendered="#{apprMB.taskDefKey == 'approveNewItemAdmin'}">
								<p:inputText id="codigo_item" required="true"
									value="#{apprMB.itemId}" label="Codigo">
								</p:inputText>
							</p:column>
							<p:column style="max-width: 64px;"
								rendered="#{apprMB.taskDefKey == 'approveNewItemAdmin'}">
								<p:message for="codigo_item" showDetail="true"
									id="codigoItemMessage"></p:message>
							</p:column>
							<p:column
								rendered="#{apprMB.taskDefKey == 'approveNewItemAdmin'}">
								<p:commandButton actionListener="#{apprMB.approveItem}"
									value="Aprobar" icon="ui-icon-check"
									update=":approveForm:item_approve_panel"></p:commandButton>
							</p:column>
							<p:column
								rendered="#{apprMB.taskDefKey == 'aprobacionItemNuevoProd'}">
								<p:commandButton actionListener="#{apprMB.approveItemProd}"
									value="Aprobar" icon="ui-icon-check"
									update=":approveForm:item_approve_panel"></p:commandButton>
							</p:column>
							<p:column>
								<p:commandButton value="Rechazar" process="@this"
									oncomplete="commentDialog.show()" icon="ui-icon-close"
									update=":approveForm:item_approve_panel">
								</p:commandButton>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:outputPanel>

				<!-- ESPECIFICACIONES DE PRODUCCION -->
				<p:outputPanel
					rendered="#{apprMB.taskDefKey == 'authorize_prod_spec' || apprMB.taskDefKey == 'authordizeQuality'}">
					<common:prodSpecs id="produsctSpecs"
						ordenProd="#{prodSpecMB.ordenProd}" locale="es"></common:prodSpecs>
					<p:panelGrid styleClass="tableNoGrid">
						<p:row>
							<p:column>
								<p:commandButton actionListener="#{apprMB.approveProdSpecs}"
									value="Aprobar" icon="ui-icon-check"
									update=":approveForm:produsctSpecs"></p:commandButton>
								<p:commandButton value="Rechazar" process="@this"
									oncomplete="commentDialog.show()" icon="ui-icon-close">
								</p:commandButton>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:outputPanel>

				<p:dialog showEffect="clip" hideEffect="clip"
					header="Comentario de rechazo" id="commentDialogId"
					widgetVar="commentDialog" focus="comment">
					<h:panelGrid style="margin-bottom:10px">
						<p:row>
							<p:column>
								<h:outputLabel for="comment" value="Comentario" />
								<p:inputTextarea id="comment" value="#{apprMB.comment}" rows="2"
									counter="counter" maxlength="150"
									counterTemplate="{0} caracteres restantes."
									style="width: 100%;" />
								<h:outputText id="counter" style="margin-bottom:10px;" />
							</p:column>
						</p:row>
					</h:panelGrid>
					<p:commandButton id="submitButton" value="Agregar Comentario"
						process="@this,comment" actionListener="#{apprMB.rejectTask}"
						icon="ui-icon-comment" update=":approveForm" />
					<p:commandButton id="cancelButton" value="Cancelar"
						oncomplete="commentDialog.hide();" process="@this"
						icon="ui-icon-cancel"></p:commandButton>
				</p:dialog>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>